package mess;

import java.util.Arrays;

public class LeeCode_26 {
    public static void main(String[] args) {
        int[] nums = {1,1,2};
        System.out.println(removeDuplicates(nums));
    }
    private static int removeDuplicates(int[] nums) {
        int index = 1;
        int len = nums.length;
        int[] nums2 = new int[len];
        Arrays.sort(nums);
        nums2[0] = nums[0];
        int count = 1;
        for (int i = 1; i < len; i++) {
            if (nums[i] == nums[i - 1])
                continue;
            nums2[index] = nums[i];
            index++;
            count++;
        }
        for (int i = 0; i < count; i++)
            nums[i] = nums2[i];
        return count;
    }
}
